/**
 * Created by liu on 2018/1/11.
 */

export const setPage = filter => {
    return {params:{'pageNum': filter.pageNum, 'pageSize': filter.pageSize}};
};

export const setParams = param => {
    let params = {params:{'pageNum': param.filter.pageNum, 'pageSize': param.filter.pageSize}};
    if ("" !== param.search.value && undefined !== param.search.value) {
        params.params[param.search.key] = param.search.value;
    }
    return params;
};

export const getListData = (fun, _this) => {
    const params = setParams(_this);
    fun(params).then(data => {
        _this.listData = data.list;
        _this.total = data.total;
        if (data.navigatePages < data.pageSize) {
            _this.filter.pageNum = 1;
        }
        _this.loading = false;
    })
};